package project2.entity;

import project2.ui.game.GamePlayingPanel;

import java.awt.*;

/**
 * 飞行物（抽象类）
 */
public abstract class Flyable {
    private int posX;// 位置
    private int posY;
    private int width;// 宽高
    private int height;
    private int speed;// 速度
    private Image image;// 形状（图片）
    private GamePlayingPanel playingPanel;

    // 常用方法

    /**
     * 绘制飞行物
     */
    public void draw(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;
        g2d.drawImage(getImage(), posX, posY, width, height, playingPanel);
    }

    public void drawOtherImage(Graphics g, Image other) {
        Graphics2D g2d = (Graphics2D) g;
        g2d.drawImage(other, posX, posY, width, height, playingPanel);
    }

    /**
     * 获取位置和宽高
     */
    public Rectangle getRectangle() {
        return new Rectangle(posX, posY, width, height);
    }

    // get、set方法

    public int getPosX() {
        return posX;
    }

    public void setPosX(int posX) {
        this.posX = posX;
    }

    public int getPosY() {
        return posY;
    }

    public void setPosY(int posY) {
        this.posY = posY;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    public GamePlayingPanel getPlayingPanel() {
        return playingPanel;
    }

    public void setPlayingPanel(GamePlayingPanel playingPanel) {
        this.playingPanel = playingPanel;
    }
}
